package de.justphil.tcg.tcgserver.websockets.messages;

import net.jcip.annotations.Immutable;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;

// omit 'null' values when serializing to json
@Immutable
@JsonSerialize(include = Inclusion.NON_NULL)
public class TCGMessage {
	@JsonProperty
	private final String subject;
	
	@JsonProperty
	private final String l;
	
	@JsonProperty
	private final TCGJoinFragment j;
	
	@JsonProperty
	private final TCGInfoFragment i;
	
	@JsonProperty
	private final TCGProgressFragment p;
	
	@JsonProperty
	private final TCGErrorFragment e;
	
	
	
	public TCGMessage() {
		this.subject	= null;
		this.l			= null;
		this.j			= null;
		this.i			= null;
		this.p			= null;
		this.e			= null;
	}
	
	public TCGMessage(String subject) {
		this.subject	= subject;
		this.l			= null;
		this.j			= null;
		this.i			= null;
		this.p			= null;
		this.e			= null;
	}
	
	public TCGMessage(String subject, String l) {
		this.subject	= subject;
		this.l			= l;
		this.j			= null;
		this.i			= null;
		this.p			= null;
		this.e			= null;
	}
	
	public TCGMessage(String subject, String l, TCGJoinFragment j) {
		this.subject	= subject;
		this.l			= l;
		this.j			= j;
		this.i			= null;
		this.p			= null;
		this.e			= null;
	}
	
	public TCGMessage(String subject, String l, TCGJoinFragment j, TCGInfoFragment i) {
		this.subject	= subject;
		this.l			= l;
		this.j			= j;
		this.i			= i;
		this.p			= null;
		this.e			= null;
	}
	
	public TCGMessage(String subject, String l, TCGJoinFragment j, TCGInfoFragment i, TCGProgressFragment p) {
		this.subject	= subject;
		this.l			= l;
		this.j			= j;
		this.i			= i;
		this.p			= p;
		this.e			= null;
	}
	
	public TCGMessage(String subject, String l, TCGJoinFragment j, TCGInfoFragment i, TCGProgressFragment p, TCGErrorFragment e) {
		this.subject	= subject;
		this.l			= l;
		this.j			= j;
		this.i			= i;
		this.p			= p;
		this.e			= e;
	}

	public String getSubject() {
		return subject;
	}

	@JsonIgnore
	public TCGJoinFragment getJoinFragment() {
		return j;
	}
	
	@JsonIgnore
	public String getLocale() {
		return l;
	}

	@JsonIgnore
	public TCGInfoFragment getInfoFragment() {
		return i;
	}
	
	@JsonIgnore
	public TCGProgressFragment getProgressFragment() {
		return p;
	}
	
	@JsonIgnore
	public TCGErrorFragment getErrorFragment() {
		return e;
	}

}
